Skip to content

feat: structured logs /api/webhooks with correlation IDs - #711

Merged
greatest0fallt1me merged 3 commits into
Predictify-org:mainfrom
codenerde:task/webhooks-logs-v7
Jul 29, 2026
Merged

feat: structured logs /api/webhooks with correlation IDs#711
greatest0fallt1me merged 3 commits into
Predictify-org:mainfrom
codenerde:task/webhooks-logs-v7

Conversation

@codenerde

Copy link
Copy Markdown

Summary

Add structured access logs on /api/webhooks with correlation ID support, following the same pattern used by all other API routes (/api/users, /api/auth, /api/markets, /api/feature-flags, etc.).

Changes

src/middleware/accessLog.ts

  • Added webhooks_access_log log name mapping for requests starting with /api/webhooks

src/routes/webhooks.ts

  • Imported and mounted accessLog middleware as the first middleware on the router
  • Updated JSDoc to document the structured access log behavior
  • All webhook endpoints now emit a structured webhooks_access_log entry on response finish
  • The X-Correlation-Id response header is set on all webhook responses

tests/webhooksAccessLog.test.ts (new)

  • 21 focused unit tests covering:
    • Log name emission (webhooks_access_log)
    • All HTTP methods (GET, POST, PATCH, DELETE)
    • Correlation ID resolution (header, fallback, UUID generation)
    • Status codes (200, 400, 404, 500)
    • Actor capture (authenticated + anonymous)
    • Response header echo
    • All required payload fields (method, path, statusCode, durationMs, ip, size, actor)
    • Sub-path handling under /api/webhooks
    • IP resolution (X-Forwarded-For + fallback)

Testing

  • All 21 new tests pass: npx jest tests/webhooksAccessLog.test.ts
  • ESLint passes with zero errors
  • Follows the same patterns used in tests/usersAccessLog.test.ts and tests/featureFlagsAccessLog.test.ts

Related

Closes #429

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@codenerde Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit e528bd0 into Predictify-org:main Jul 29, 2026
1 check passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

LGTM ✅ green CI, clean work — merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add structured logs on /api/webhooks (v7)

3 participants